---
id: "async"
keywords: ["async"]
name: "async"
summary: "This is the `async` keyword."
category: "languageconstructs"
---

**Since 10.1**

Use the `async` keyword to make a function asynchronous. An async function may use the [await](./language_await.mdx) keyword to unwrap a promise value in a seamingly synchronous manner.

### Example

<CodeTab labels={["ReScript", "JS Output"]}>

```res
// Some fictive functionality that offers asynchronous network actions
@val external fetchUserMail: string => promise<string> = "GlobalAPI.fetchUserMail"
@val external sendAnalytics: string => promise<unit> = "GlobalAPI.sendAnalytics"

// We use the `async` keyword to allow the use of `await` in the function body
let logUserDetails = async (userId: string) => {
  // We use `await` to fetch the user email from our fictive user endpoint
  let email = await fetchUserMail(userId)

  await sendAnalytics(`User details have been logged for ${userId}`)

  Console.log(`Email address for user ${userId}: ${email}`)
}
```

```js
async function logUserDetails(userId) {
  var email = await GlobalAPI.fetchUserMail(userId);
  await GlobalAPI.sendAnalytics(
    "User details have been logged for " + userId + "",
  );
  console.log("Email address for user " + userId + ": " + email + "");
}
```

</CodeTab>

### References

- [Async & Await](../docs/manual/async-await.mdx)
